﻿Imports TNCDAL
Public Class ucDetailPaymentVoucher
    Dim mBR As New MBuyingRate
    Private Sub ucDetailPaymentVoucher_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim util As New Utilities
        util.FillFeeTree(treeFileFee, 81)

    End Sub
    Public Sub showControl(ByVal obj As System.Windows.Forms.Control)
        PanelEx1.Controls.Clear()
        obj.Dock = DockStyle.Fill
        PanelEx1.Controls.Add(obj)
    End Sub
    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        'hiển thị form lập phiếu chi
        Dim arrayFee As New ArrayList
        Dim totalPrice As Double = 0
        For Each n As TreeNode In GetCheck(treeFileFee.Nodes)
            ' MessageBox.Show(n.Name, n.Text)
            'Có danh sách các phí thì tính tổng tiền và in ra phiếu chi
            arrayFee.Add(n.Name)
            totalPrice += mBR.getPriceFollowFee(n.Name)
        Next
        ' MessageBox.Show(totalPrice)
        'Dim frm As New frmPaymentVoucher(0, totalPrice)
        'frm.ShowDialog()
        Dim uc As New ucPaymentVoucher(arrayFee, totalPrice)
        showControl(uc)
    End Sub
    Private Function GetCheck(ByVal node As TreeNodeCollection) As List(Of TreeNode)
        Dim lN As New List(Of TreeNode)
        For Each n As TreeNode In node
            If n.Checked Then lN.Add(n)
            lN.AddRange(GetCheck(n.Nodes))
        Next

        Return lN
    End Function
End Class
